<?php
session_start();
// 未登录则重定向到登陆页面
if (!isset($_SESSION['username'])) {
    header("Location:login.php");
    exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
    <script src="js/ajax.in.js"></script>
    <script src="tinymce/js/tinymce/tinymce.min.js"></script>
    <script>tinymce.init({
            selector: 'textarea',
            theme: "modern",
            language: "zh_CN",
            plugins: "advlist, anchor, autolink, autoresize, autosave, bbcode, charmap, code, codesample, colorpicker, compat3x, contextmenu, directionality, emoticons, fullpage, fullscreen, help, hr, image, imagetools, importcss, insertdatetime, legacyoutput, link, lists, media, nonbreaking, noneditable, pagebreak, paste, preview, print, save, searchreplace, spellchecker, tabfocus, table, template, textcolor, textpattern, toc, visualblocks, visualchars, wordcount, emoticons",
            // 使用的插件,有很多插件和工具栏按钮重复,可以去掉
            // 这里加载所有插件
            branding: false
        });</script>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"></meta>
    <title>发表留言</title>
    <script language="JavaScript">
        function InputCheck(form1) {
            if (form1.nickname.value == "") {
                alert("请输入您的昵称。");
                form1.nickname.focus();
                return (false);
            }
            if (form1.content.value == "") {
                alert("留言内容不可为空。");
                form1.content.focus();
                return (false);
            }
        }
    </script>
</head>
<body>
<div class="form">
    <form id="form1" name="form1" method="post" action="submiting.php"
          onsubmit="return InputCheck(this)">
        <h3>发表留言</h3>
        <p>
            <label for="title">昵&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;称:</label>
            <input type="text" name="nickname" value="<?= $_SESSION['username'] ?>" disabled="disabled"/>
        </p>
        <p>
            <label for="title">电子邮件:</label> <input id="email" name="email"
                                                    type="text"/><span>(非必须，不超过60个字符串)</span>
        </p>
        <p>
            <label for="title">留言内容:</label>
            <textarea id="content" name="content" cols="50" rows="8"></textarea>
        </p>
        <input type="button" onclick="history.go(-1)"
               value="返回"></input>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<!-- <input
			type="submit" name="submit" value="  确 定  " /> -->
        <button type="button" onclick="Add()">确定</button>

    </form>
</div>
</body>
</html>